//
//  CollectionReusableView.m
//  HimalayaMusic
//
//  Created by dllo on 16/1/8.
//  Copyright © 2016年 WXCLegendary. All rights reserved.
//

#import "CollectionReusableView.h"

@implementation CollectionReusableView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = kColor;
        self.titleLable = [[UILabel alloc] init];
        self.titleLable.backgroundColor = kColor;
        self.moreButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.moreButton.backgroundColor = kColor;
        self.titleLable.frame = CGRectMake(5, 5, (self.width - 10) / 2 , self.height - 10);
        self.moreButton.frame = CGRectMake((self.width - 10) / 4 * 3, 5, (self.width - 10) / 4, self.height - 10);
        [self.moreButton setTitle:@"查看更多" forState:UIControlStateNormal];
        [self.moreButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.moreButton addTarget:self action:@selector(moreButton:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:self.titleLable];
        [self addSubview:self.moreButton];
    }
    return self;
}



-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    self.titleLable.text = self.string;
    self.titleLable.font = [UIFont systemFontOfSize:14];
    
    self.moreButton.titleLabel.font = [UIFont systemFontOfSize:14];
}

- (void)moreButton:(UIButton *)button {
    
    
    [self.delegate changeAndGet:self.name withConditon:self.ids];
    
}


- (void)setString:(NSString *)string {
    if (_string != string) {
        _string = string;
    }
    self.titleLable.text = self.string;
}
- (void)awakeFromNib {
    // Initialization code
}

@end
